<template>
	<view class="content_info">
		<view class="content">
			<view>
				<text>
					姓名:{{infoData.name}}
				</text>
			</view>
			<view>
				<text>
					年龄:{{infoData.age}}
				</text>
			</view>

			<view>
				<text>
					职业:{{infoData.occupation}}
				</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		findInfo
	} from '@/api/api.js'

	export default {
		data() {
			return {
				infoData: {
					name: undefined,
					age: undefined,
					occupation: undefined
				}
			}
		},
		
		onPullDownRefresh() {
			console.log('refresh');
			this.findData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
		},
		
		onLoad: function(option) {
			// console.log('触发初始化函数')
			this.findData()
		},

		methods: {
			findData() {
				findInfo().then(res => {
					this.infoData.name = res.data.name
					this.infoData.age = res.data.age
					this.infoData.occupation = res.data.occupation
				})
			}
		}
	}
</script>

<style>
	.content_info {
		display: flex;

		.content {
			margin: auto;
			margin-top: 400rpx;
		}
	}
</style>